﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;

namespace XEvents.Library
{
    internal struct dm_xe_object
    {
        internal string name;
        internal string object_type;
        internal Guid package_guid;
        internal string description;
        internal int capabilities;
        internal string capabilities_desc;
        internal string type_name;
        internal Guid type_package_guid;
        internal int type_size;

        internal dm_xe_object(SqlDataReader dr)
        {
            name = (dr["name"] == DBNull.Value ? string.Empty : dr["name"]).ToString();
            object_type = (dr["object_type"] == DBNull.Value ? string.Empty : dr["object_type"]).ToString();
            Utilities.IsGuid((dr["package_guid"] == DBNull.Value ? string.Empty : dr["package_guid"]).ToString(), out package_guid);
            description = (dr["description"] == DBNull.Value ? string.Empty : dr["description"]).ToString();
            Int32.TryParse((dr["capabilities"] == DBNull.Value ? "-1" : dr["capabilities"]).ToString(), out capabilities);
            capabilities_desc = (dr["capabilities_desc"] == DBNull.Value ? string.Empty : dr["capabilities_desc"]).ToString();
            type_name = (dr["type_name"] == DBNull.Value ? string.Empty : dr["type_name"]).ToString();
            Utilities.IsGuid((dr["type_package_guid"] == DBNull.Value ? string.Empty : dr["type_package_guid"]).ToString(), out type_package_guid);
            Int32.TryParse((dr["type_size"] == DBNull.Value ? "-1" : dr["type_size"]).ToString(), out type_size);
        }
    }
}
